package com.unit.handler;

import com.unit.util.EnumUtils;

public class EnumHandler implements DataObjectHandler {

	@Override
	public Object convert(String data, Class<?> propType) {
		if (Enum.class.isAssignableFrom(propType)) {
			try {
				return EnumUtils.getEnumByRefection(propType, Integer.parseInt(data));
			} catch (Throwable e) {
				throw new RuntimeException("Enum格式转换异常："+e.getMessage());
			}
		}
		return null;
	}

}
